package com.healthcloud.service.impl;

import java.util.List;

import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.healthcloud.dao.FoodGuidanceMapper;
import com.healthcloud.entity.FoodGuidance;
import com.healthcloud.service.FoodGuidanceService;
import com.healthcloud.utils.PageParam;

/**
 * Created by houxianghua on 2016/5/10.
 */
@Service
@Transactional
public class FoodGuidanceServiceImpl implements FoodGuidanceService {

    @Autowired
    private FoodGuidanceMapper foodGuidanceMapper;

    @Override
    public int save(FoodGuidance foodGuidance) {
        foodGuidance.setCreatedTime(new DateTime());
        foodGuidance.setUpdatedTime(new DateTime());
        return foodGuidanceMapper.save(foodGuidance);
    }

    @Override
    public int update(FoodGuidance foodGuidance) {
        foodGuidance.setUpdatedTime(new DateTime());
        return foodGuidanceMapper.update(foodGuidance);
    }

    @Override
    public int delete(Long id) {
        return foodGuidanceMapper.delete(id);
    }

    @Override
    public List<FoodGuidance> findByEntity(FoodGuidance foodGuidance) {
        return foodGuidanceMapper.findByEntityAll(foodGuidance);
    }

    @Override
    public List<FoodGuidance> findByLikeName(String foodName) {
        return foodGuidanceMapper.findByLikeName(foodName);
    }

    @Override
    public List<FoodGuidance> getHotFood(String foodName, PageParam pageParam) {
        return foodGuidanceMapper.getHotFood(foodName, pageParam);
    }

    @Override
    public List<FoodGuidance> getNewFood(String foodName, PageParam pageParam) {
        return foodGuidanceMapper.getNewFood(foodName, pageParam);
    }
}
